<template>
  <div>
    <button @click="isShow = !isShow">a.显示/隐藏</button> - 动画实现
    <transition name="test1" appear>
      <h1 v-show="isShow">a.你好啊</h1>
    </transition>
    <br />
    <button @click="isShow2 = !isShow2">b.显示/隐藏</button> - 过渡实现
    <transition name="test2" appear>
      <h1 v-show="isShow2">b.你好啊</h1>
    </transition>
    <br />
    <button @click="isShow3 = !isShow3">c.显示/隐藏</button> - transition group
    <transition-group name="test2" appear>
      <h1 v-show="!isShow3" key="1">c.你好啊 - 1</h1>
      <h1 v-show="isShow3" key="2">c.你好啊 - 2</h1>
    </transition-group>
    <br />
    <button @click="isShow4 = !isShow4">d.显示/隐藏</button> - 第三方动画库
    animate.css
    <transition-group
      appear
      name="animate__animated animate__bounce"
      enter-active-class="animate__swing"
      leave-active-class="animate__backOutUp"
    >
      <h1 v-show="!isShow4" key="1">d.你好啊 - 1</h1>
      <h1 v-show="isShow4" key="2">d.你好啊 - 2</h1>
    </transition-group>
  </div>
</template>

<script>
import 'animate.css'
export default {
  name: 'Carton',
  data() {
    return {
      isShow: true,
      isShow2: true,
      isShow3: true,
      isShow4: true,
    }
  },
  created() {},
  methods: {},
}
</script>

<style scoped>
h1 {
  background-color: pink;
}

.test1-enter-active {
  animation: moving 0.5s;
}
.test1-leave-active {
  animation: moving 0.5s reverse;
}

@keyframes moving {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0px);
  }
}

.test2-enter-active,
.test2-leave-active {
  transition: 0.5s linear;
}
/* 进入的起点 离开的终点*/
.test2-enter,
.test2-leave-to {
  transform: translateX(-100%);
}
/* 进入的终点, 离开的起点*/
.test2-enter-to,
.test2-leave {
  transform: translateX(0);
}
</style>
